package rabbit;


import java.net.InetAddress;
import java.net.UnknownHostException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.test.context.junit4.SpringRunner;
import entity.FahaiMongoEntity;
import controller.SimpleController;


@RunWith(SpringRunner.class)
@Import({ Senders.class}) 
@ComponentScan(basePackages = { "rabbit" })
@EnableMongoRepositories(basePackages="mongoMapper" ) 
@SpringBootTest(classes = SimpleController.class)
public class TestRabbitController {
	

	@Autowired(required = true)
    public Senders senders;
    @Test
    public void hello() throws Exception {
    	for(int i=0;i<1;i++) {
    		FahaiMongoEntity fahaiMongoEntity = new FahaiMongoEntity();
    		fahaiMongoEntity.setEntryId("111---"+i);
    		fahaiMongoEntity.setBody("ddd---"+i);
    		try {
				fahaiMongoEntity.setPname(InetAddress.getLocalHost().getHostName());
			System.out.println("-----------------------------------"+fahaiMongoEntity.getBody());
			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		 senders.send(fahaiMongoEntity);
    	}
    	
       
    }

}
